home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / libraries / curses210.lha / src / tgetnum.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-22  |  2.4 KB  |  88 lines

  1. /* -*-C-*-
  2.  *
  3.  *
  4.  * Filename : Workbench2.0:src/curses/tgetnum.c
  5.  *
  6.  * Author   : Simon J Raybould.    (sie@fulcrum.co.uk).
  7.  *
  8.  * Date     : Thu Feb 25 21:28:42 1993
  9.  *
  10.  * Desc     : Gets a numeric value of capability id.
  11.  *
  12.  *
  13.  * THIS CODE IS NOT PUBLIC DOMAIN
  14.  * ==============================
  15.  * 
  16.  * This code is copyright Simon J Raybould 1992, all rights are reserved.
  17.  * All code, ideas, data structures and algorithms remain the property of the
  18.  * author. Neither the whole nor sections of this code may be used as part
  19.  * of other code without the authors consent. If you wish to use some of this
  20.  * code then please email me at (sie@fulcrum.bt.co.uk).
  21.  *
  22.  * This source is not public domain, so you do not have any right to alter it
  23.  * or sell it for personal gain. The source is provided purely for reference
  24.  * purposes. You may re-compile the source with any compiler you choose.
  25.  * You must not distribute altered copies without the authors consent. My
  26.  * intention is that the source will help people isolate any bugs much more
  27.  * effectively.
  28.  *
  29.  * Disclaimer
  30.  * ==========
  31.  *
  32.  * No implication is made as to this code being fit for any purpose at all.
  33.  * I (the author) shall not be held responsible for any loss of data or damage 
  34.  * to property that may result from its use or misuse.
  35.  *
  36.  *
  37.  * Revision History
  38.  * ================
  39.  *
  40.  * $Log: tgetnum.c,v $
  41.  * Revision 1.1  1993/05/17  23:33:10  sie
  42.  * Initial revision
  43.  *
  44.  *
  45.  */
  46.  
  47. #ifndef lint
  48. static char *rcsid = "$Header: /SRC/lib/curses/src/RCS/tgetnum.c,v 1.1 1993/05/17 23:33:10 sie Exp $";
  49. #endif /* lint */
  50.  
  51.  
  52. #include "acurses.h"
  53.  
  54.  
  55. tgetnum(char *id)
  56. {
  57.   int i;
  58.   
  59.   if(strlen(id) != CAP_LEN)
  60.     return -1;
  61.   
  62. #ifdef FUTURE                   /* These are the starts of future enhancements */
  63.                                 /* or is it a Leonard Cohen album ? */
  64.   if(_CursesType == CUST_CURSES) {
  65.     switch(*((short *)id)) {
  66.     case 0x6c69:                /* li */
  67.       return LINES;
  68.       break;
  69.     case 0x636f:                /* co */
  70.       return COLS;
  71.       break;
  72.     }
  73.   } else {
  74. #endif
  75.   /* find the capability string */
  76.   for(i=0; i< __no_caps; i++) {
  77.     if(!strncmp(id, __capary[i], CAP_LEN)) { /* if it's this one */
  78.       if(__capary[i][2] != '#') /* if it's not a number capability */
  79.         return -1;
  80.       return atoi(&__capary[i][3]);
  81.     }
  82.   }
  83. #ifdef FUTURE
  84.   }
  85. #endif
  86.   return -1;                    /* not found */
  87. }
  88.